#!/bin/bash -x

# 获取你的发行版，例如：ubuntu18.04
distribution=$(. /etc/os-release;echo IDVERSION_ID)

# 添加NVIDIA的GPG密钥
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -

# 添加NVIDIA Docker的仓库
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list

sudo apt-get update

# 更新软件包列表
sudo apt-get update

# 安装nvidia-docker2包
sudo apt-get install -y nvidia-docker2

# 重启Docker服务
# sudo systemctl restart docker
